import React from 'react';
import { Dayjs } from 'dayjs';

export type TimePickerPlacement = 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
export type TimePickerState = 'error' | 'warning';
export type CustomFormat<DateType> = (value: DateType) => string;

export type DisabledTimes = {
    disabledHours?: () => number[];
    disabledMinutes?: (hour: number) => number[];
    disabledSeconds?: (hour: number, minute: number) => number[];
};

export type DisabledTime<DateType> = (date: DateType | null) => DisabledTimes;

export interface TimePickerEvents<DateType> {
    onChange?: (value: DateType | null, dateString: string) => void;
    onOpenChange?: (open: boolean) => void;
    onFocus?: React.FocusEventHandler<HTMLInputElement>;
    onBlur?: React.FocusEventHandler<HTMLInputElement>;
    onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
    onMouseUp?: React.MouseEventHandler<HTMLDivElement>;
    onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
    onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
    onClick?: React.MouseEventHandler<HTMLDivElement>;
    onContextMenu?: React.MouseEventHandler<HTMLDivElement>;
    onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, preventDefault: () => void) => void;
}

export interface TimePickerProps extends TimePickerEvents<Dayjs> {
    allowClear?: boolean;
    autoFocus?: boolean;
    bordered?: boolean;
    clearIcon?: React.ReactNode;
    clearText?: string;
    className?: string;
    disabled?: boolean;
    disabledTime?: DisabledTime<Dayjs>;
    dropdownClassName?: string;
    defaultValue?: Dayjs;
    // format?: string | CustomFormat<Dayjs> | (string | CustomFormat<Dayjs>)[];
    format?: string;
    getPopupContainer?: string | null;
    hideDisabledOptions?: boolean;
    hourStep?: number;
    id?: string;
    inputReadOnly?: boolean;
    minuteStep?: number;
    open?: boolean;
    placement?: TimePickerPlacement;
    placeholder?: string;
    prefixCls?: string;
    popupClassName?: string;
    popupStyle?: React.CSSProperties;
    renderExtraFooter?: React.ReactNode;
    secondStep?: number;
    showNow?: boolean;
    suffixIcon?: React.ReactNode;
    status?: TimePickerState;
    style?: React.CSSProperties;
    use12Hours?: boolean;
    value?: Dayjs;
}

export interface PickerPanelProps {
    isOpen: boolean;
    value?: Dayjs;
    prefixCls?: string;
    style: React.CSSProperties;
}